package struts.form;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

public class FullForm extends ActionForm {
	public static ActionForm full(String formPath, HttpServletRequest request) {
		ActionForm actionForm = null;

		try {
			Class clazz = Class.forName(formPath);
			actionForm = (ActionForm) clazz.newInstance();
			Field[] fields = clazz.getDeclaredFields();
			for (Field f : fields) {
				f.setAccessible(true);
				f.set(actionForm, request.getParameter(f.getName()));
				f.setAccessible(false);
			}
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Form装载失败。。。。。");
		}

		return actionForm;
	}
}
